package com.weixin.paleituo.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.weixin.paleituo.R;
import com.weixin.paleituo.activity.GoodsDetailsActivity;
import com.weixin.paleituo.base.ComAdapter;
import com.weixin.paleituo.bean.ChildrenBean;
import com.weixin.paleituo.help.ViewHolder;
import com.weixin.paleituo.util.StringUtils;
import com.weixin.paleituo.util.UIUtils;

import java.util.List;

/**
 * Author yichao
 * Time  2018/1/12 9:27
 * Dest  推荐商品
 */
public class ClassifyRecommadGoodsGridViewAdapter extends ComAdapter<ChildrenBean> {

    private TextView mTvname,mTvMoney;
    private ImageView mImageView;

    public ClassifyRecommadGoodsGridViewAdapter(Context context, List<ChildrenBean> childrenBeans) {
        super(context,childrenBeans,R.layout.item_classify_recommandgoods);
    }

    @Override
    public void convert(ViewHolder holder, final ChildrenBean childrenBean, int position) {
        mImageView = holder.getItemView(R.id.iv_item_classify_recommand_goods);
        mTvname = holder.getItemView(R.id.tv_name_item_classify_recommand_goods);
        mTvMoney = holder.getItemView(R.id.tv_money_item_classify_recommand_goods);

      ImageView imageView=  holder.getItemView(R.id.iv_vip_item_classify_recommanddgoods);

        if (!StringUtils.isEmpty(childrenBean.getSpecialSales())){
            mTvMoney.setText("￥"+UIUtils.getMoney(Double.valueOf(childrenBean.getSpecialSales())));
            mTvMoney.setTextColor(UIUtils.getColor(R.color.c_29CE7E));
            imageView.setVisibility(View.VISIBLE);
        }else {
            mTvMoney.setText("￥"+UIUtils.getMoney(childrenBean.getPrice()));
            mTvMoney.setTextColor(UIUtils.getColor(R.color.c_ed5240));
            imageView.setVisibility(View.INVISIBLE);
        }
      //  Glide.with(mContext).load(childrenBean.getImg()).placeholder(R.mipmap.commodity_1).into(mImageView);
        UIUtils.loadImageView(mContext,childrenBean.getImg(),mImageView);

        mTvname.setText(childrenBean.getName()+"");
        holder.getmConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              //  ClassifyGoodsListActivity.startActivity(mContext);
               GoodsDetailsActivity.startActivity(mContext,childrenBean.getId());
            }
        });

    }
}
